//
//  YKQAddViewController.m
//  YaoKongQi
//
//  Created by ryou on 2021/5/19.
//
#define kBtnIconArray @[@"ykq_btn_kaiguan.png",@"ykq_btn_zidong.png",@"ykq_btn_shuimian.png",@"ykq_btn_chuifeng.png",@"ykq_btn_zhileng.png",@"ykq_btn_dingshi.png"]
#import "YKQDetailViewController.h"
#import "YKQMoreViewController.h"
@interface YKQDetailViewController ()
@property(nonatomic,assign)NSInteger wendu;
@property(nonatomic,strong)UILabel *wenduLabel;
@end

@implementation YKQDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _wendu=26;
    self.title = @"遥控器";
    
    UIImageView *headView=[[UIImageView alloc]initWithFrame:CGRectMake(20, 100, kYKQWidth  - 40, 120)];
    headView.image = [UIImage imageNamed:@"ykq_icon_white_bg.png"];
    headView.contentMode=UIViewContentModeScaleToFill;
    [self.view addSubview:headView];
    headView.userInteractionEnabled=YES;
 
    UIImageView *icon=[[UIImageView alloc]init];
//    icon.image = [UIImage imageNamed:@"ykq_icon_duankailianjie.png"];
    icon.frame = CGRectMake(30, headView.frame.size.height/2 - 20, 40, 40);
    [headView addSubview:icon];
    
    
    UILabel *nameLabel=[[UILabel alloc]initWithFrame:CGRectMake(icon.frame.size.width + icon.frame.origin.x + 20, 15, 300, headView.frame.size.height/2 -15)];
    nameLabel.text =  @"红外设备";
    nameLabel.textColor=kRedColor;
    [headView addSubview:nameLabel];
    nameLabel.font=[UIFont systemFontOfSize:18];
    
    
    UILabel *tipsLabel=[[UILabel alloc]initWithFrame:CGRectMake(icon.frame.size.width + icon.frame.origin.x + 20, headView.frame.size.height/2, 300, headView.frame.size.height/2 -15)];
    tipsLabel.text =  @"当前状态：已连接";
    tipsLabel.textColor=kBlackColor;
    [headView addSubview:tipsLabel];
    tipsLabel.font=[UIFont systemFontOfSize:16];
    
    
    UILabel *wenduLable=[[UILabel alloc]initWithFrame:CGRectMake(0, headView.frame.size.height  + headView.frame.origin.y + 20, kYKQWidth, 100)];
    wenduLable.text =  @"26°C";
    wenduLable.textColor=kRedColor;
    [self.view addSubview:wenduLable];
    wenduLable.textAlignment=NSTextAlignmentCenter;
    wenduLable.font=[UIFont systemFontOfSize:80];
    _wenduLabel=wenduLable;
    
    CGFloat itemW  = 100;
    CGFloat space = (kYKQWidth - itemW * 3)/4;
    for (int i=0; i  < kBtnIconArray.count ; i++) {
        
        UIButton  *button=[[UIButton alloc]initWithFrame:CGRectMake(space +(space+itemW)*(i%3),wenduLable.frame.size.height+ wenduLable.frame.origin.y + (itemW + space)*(i/3), itemW, itemW)];
        [button setImage:[UIImage imageNamed:kBtnIconArray[i]] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(ykqBtnClick) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:button];
        //        button.backgroundColor=[UIColor redColor];
        button.tag = i;
    }
    
    UIImageView *jiajianBg=[[UIImageView alloc]initWithFrame:CGRectMake(kYKQWidth /2 - 100,wenduLable.frame.size.height+ wenduLable.frame.origin.y + (itemW + space)*(2),   200, 74)];
    jiajianBg.image=[UIImage imageNamed:@"ykq_icon_white_bg.png"];
    [self.view addSubview:jiajianBg];
    jiajianBg.userInteractionEnabled=YES;
 
    
    UIButton *jian=[[UIButton alloc]initWithFrame:CGRectMake(20, 17, 40, 40)];
    [jian  setImage:[UIImage imageNamed:@"ykq_icon_jian.png"] forState:UIControlStateNormal];
    [jian addTarget:self action:@selector(jianBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [jiajianBg addSubview:jian];
 
    
    UIButton *jia=[[UIButton alloc]initWithFrame:CGRectMake(jiajianBg.frame.size.width - 40 - 20, 17, 40, 40)];
    [jia  setImage:[UIImage imageNamed:@"ykq_icon_jia.png"] forState:UIControlStateNormal];
    [jia addTarget:self action:@selector(jiaBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [jiajianBg addSubview:jia];
    
    [self ykqBUAdLoadBanner];

    // Do any additional setup after loading the view.
}
-(void)jianBtnClick{

    _wendu -- ;
    if (_wendu<17) {
        _wendu=17;
        return;
    }
    _wenduLabel.text=[NSString stringWithFormat:@"%ld°C",_wendu];
    
}

-(void)jiaBtnClick{
    _wendu ++ ;
    if (_wendu>35) {
        _wendu=35;
        return;
    }
    _wenduLabel.text=[NSString stringWithFormat:@"%ld°C",_wendu];
}

-(void)ykqBtnClick{
    
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
